package com.kdgz.kdgz.controller;

import com.kdgz.kdgz.beans.Finance;
import com.kdgz.kdgz.sevice.FinanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.time.Month;
import java.util.List;

/**
 * @Author Veneno
 * @Desc
 * @date 2021/3/22
 */
@RestController
public class FinanceController {
    @Autowired
    FinanceService financeService;

    /**
     * 得到所有的财务信息
     *
     * @return {@link List<Finance>}
     */
    @GetMapping("/finances")
    public List<Finance> getAll(){
        return financeService.getAllFinance();
    }

    /**
     * 得到一年的财务信息
     *
     * @param year 一年
     * @return {@link List<Finance>}
     */
    @GetMapping("/finance/{year}")
    public List<Finance> getByYear(@PathVariable("year") Integer year){
        return financeService.getFinanceByYear(year);
    }

    /**
     * 得到某年某月的财务信息
     *
     * @param year  一年
     * @param month 月
     * @return {@link Finance}
     */
    @GetMapping("/finance/{year}/{month}")
    public Finance getByYearAndMonth(@PathVariable("year") Integer year, @PathVariable("month") Integer month){
        return financeService.getFinanceByMonth(year,month);
    }
}
